package de.cau.apo.samples;

import java.io.FileNotFoundException;
import java.io.IOException;

import de.cau.apo.CommunicationInterface;
import de.cau.apo.problems.binpacking.BPInstance;
import de.cau.apo.problems.binpacking.BPSolution;
import de.cau.apo.problems.binpacking.Item;

public class BinPackingSample {

	public static void main(String[] args) throws FileNotFoundException, IOException {
		// create instance parse instance file
		BPInstance instance = new BPInstance();
		instance.parseInstance(CommunicationInterface.getInstance());
		// create solution by putting every item into a new bin
		BPSolution solution = new BPSolution(instance);
		for (Item item : instance.getItems()) {
			solution.createNewBin().addItem(item);
		}
		// publish solution and do debug information output
		if (CommunicationInterface.publishSolution(solution)) {
			System.err.println("Solution is feasible");
		} else {
			System.err.println("Solution is not feasible");
		}
	}

}
